package com.flame.workflow.id.controller;

import java.util.List;

import com.flame.core.protocol.Result;
import com.flame.workflow.id.entity.WorkflowOrganization;
import com.flame.workflow.id.service.IdentityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 *
 * @author wuxintong😺😺😺
 * @since 2023/11/6
 */
@RestController
public class IdentityController {

    @Autowired
    private IdentityService identityService;

    @PostMapping("/id/user/list")
    public Result userList(@RequestBody List<String> userIdList) {
        return Result.success(identityService.listWorkflowUserByUserIds(userIdList));
    }

    @PostMapping("/id/role/list")
    public Result roleList() {
        return Result.success(identityService.listWorkflowRole());
    }

    @PostMapping("/id/role/query")
    public Result roleList(@RequestBody List<String> roleCodeList) {
        return Result.success(identityService.listWorkflowRoleByRoleCodes(roleCodeList));
    }

    @PostMapping("/id/dept/list")
    public Result deptList() {
        return Result.success(identityService.listWorkflowOrganization());
    }

    @PostMapping("/id/dept/user/list")
    public Result deptUserList(@RequestBody WorkflowOrganization organization) {
        return Result.success(identityService.listWorkflowUserByOrgCode(organization.getOrgCode()));
    }
}
